﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace pufflesweb
{
    public partial class tables : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PModel.User mysuer = new PModel.User();

                mysuer = (PModel.User)PF.SessionHelper.GetSession("user");

                this.username1.Text = mysuer.Username;
                //this.uphotot1.ImageUrl = "userimg/" + mysuer.Uphoto.ToString();
                this.uage1.Text = mysuer.Uage.ToString();
                this.usex1.Text = mysuer.Usex.ToString();
                this.uemail1.Text = mysuer.Uemail;
                this.uaddress1.Text = mysuer.Uaddress;
                this.unumber1.Text = mysuer.Unumber.ToString();
                this.HiddenField1.Value = mysuer.UID.ToString();

                this.username2.Text = mysuer.Username;
                //this.uphotot1.ImageUrl = "userimg/" + mysuer.Uphoto.ToString();
                this.uage2.Text = mysuer.Uage.ToString();
                this.usex2.Text = mysuer.Usex.ToString();
                this.uemail2.Text = mysuer.Uemail;
                this.uaddress2.Text = mysuer.Uaddress;
                this.unumber2.Text = mysuer.Unumber.ToString();
            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            PModel.User myuser2 = new PModel.User();
            myuser2 = (PModel.User)PF.SessionHelper.GetSession("user");
            //myuser2.UID = int.Parse(this.HiddenField1.Value);
            myuser2.Username = this.username2.Text;
            myuser2.Uage = int.Parse(this.uage2.Text);
            myuser2.Usex = int.Parse(this.usex2.Text);
            myuser2.Uemail = this.uemail2.Text;
            myuser2.Uaddress = this.uaddress2.Text;
            myuser2.Unumber = int.Parse(this.unumber2.Text);

            if (PBLL.User.update(myuser2))
            {
                PF.JsHelper.AlertAndParentUrl("修改保存成功", "index.aspx");
            }
            else
            {
                PF.JsHelper.AlertAndParentUrl("修改失败,请重新输入", "tables.aspx");
            }
        }
    }
}